package com.zmn.uac.client;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.uac.UacException;
import com.zmn.uuc.common.constant.DubboConsts;
import com.zmn.vas.common.dro.CheckDRO;
import com.zmn.vas.dubbo.interfaces.order.VasOrderListRemoteService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @title: 增值服务订单对外Dubbo接口
 * @author:Rananquan
 * @Date:2022/6/9 17:42
 */
@Slf4j
@Component
public class VasOrderListClient {

    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
    VasOrderListRemoteService vasOrderListRemoteService;

    /**
     * 根据userId集合判断是否有9块9会员
     * @param userIds 用户ID
     * @return
     */
    public List<CheckDRO> checkNineDollarsNineByUserIds(List<Long> userIds){
        log.info("根据userId集合判断是否有9块9会员入参：[{}]",userIds);
        ResponseDTO<List<CheckDRO>> checkResponse = vasOrderListRemoteService.checkNineDollarsNineByUserIds(userIds);
        if(!checkResponse.isSuccess()){
            log.error("根据userId集合判断是否有9块9会员请求失败，失败原因：{}",checkResponse.getMessage());
            throw new UacException(checkResponse.getMessage());
        }

        List<CheckDRO> checkList = checkResponse.getData();
        log.info("根据userId集合判断是否有9块9会员返回response：[{}]",checkList);

        return checkList;
    }
}
